<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" type="flex" align="middle">
          <a-col flex="450px">
            <a-form-item label="">
              <a-input-group compact>
                <a-select v-model="queryParam.searchField" @change="changeForceUpdate" :dropdownMatchSelectWidth="false">
                  <a-select-option value="projectNo"> 项目编号 </a-select-option>
                  <a-select-option value="projectName"> 项目名称 </a-select-option>
                </a-select>
                <a-input-search
                  style="width: 78%"
                  v-model="queryParam.keyword"
                  @search="searchQuery"
                  placeholder="请按照关键字进行搜索"
                />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col flex="auto">
            <span class="flex-btn-line">
              <a-button
                type="primary"
                @click="handlePostExportXls('个人项目情况报表')"                
                icon="download"
                >导出</a-button
              >
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <a-modal
        :visible="showSearchForm"
        width="70vw"
        :bodyStyle="{ padding: '10px' }"
        title="高级查询"
        @ok="handleToSearch"
        @cancel="showSearchForm = false"
      >
        <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="项目状态">
                <a-select v-model="queryParam.status">
                  <a-select-option value="1"> 创建中 </a-select-option>
                  <a-select-option value="2"> 审批中 </a-select-option>
                  <a-select-option value="3"> 上会中 </a-select-option>
                  <a-select-option value="4"> 执行中 </a-select-option>
                  <a-select-option value="5"> 验收中 </a-select-option>
                  <a-select-option value="6"> 结题 </a-select-option>
                  <a-select-option value="7"> 立项不通过 </a-select-option>
                  <a-select-option value="10"> 转储 </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目号">
                <a-input v-model="queryParam.projectNo" />
              </a-form-model-item>
            </a-col>
          </a-row>

          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="项目名称">
                <a-input v-model="queryParam.projectName" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目经理">
                <a-input v-model="queryParam.projectManagerRealName" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-modal>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator"></div>
    <span>单位：万元</span>
    <div class="container">
      <a-table
        ref="table"
        bordered
        size="middle"
        :scroll="{ x: true }"
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="changeReason" slot-scope="text">
          <span :title="text">{{ showLength(text, 15) }}</span>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
export default {
  name: 'maDeptReportList',
  mixins: [JeecgListMixin],
  data() {
    return {
      description: '个人项目情况报表',
      /* 勾选导出参数 */
      rowKey: 'projectBuildId',
      busType: 'personProjectHrList',
      columns: [
        {
          title: '项目编号',
          dataIndex: 'projectNo',
          key: 'projectNo',
          align: 'center',
          width: '100px',
        },
        {
          title: '项目名称',
          dataIndex: 'projectName',
          key: 'projectName',
          align: 'center',
          width: '100px',
        },
        {
          title: '项目状态',
          dataIndex: 'statusDesc',
          key: 'statusDesc',
          align: 'center',
          width: '80px',
        },
        {
          title: '项目角色',
          dataIndex: 'memberRoleName',
          key: 'memberRoleName',
          align: 'center',
          width: '80px',
        },
        {
          title: '成员姓名',
          dataIndex: 'memberRealName',
          key: 'memberRealName',
          align: 'center',
          width: '80px',
        },
        {
          title: '项目开始时间',
          dataIndex: 'auditPassDate',
          key: 'auditPassDate',
          align: 'center',
          width: '100px',
        },
        {
          title: '项目结束时间',
          dataIndex: 'projectEndDate',
          key: 'projectEndDate',
          align: 'center',
          width: '100px',
        },
        {
          title: '项目成果',
          dataIndex: 'projectAchievement',
          key: 'projectAchievement',
          align: 'center',
          width: '80px',
        },
      ],
      url: {
        list: '/projectBuild/personProjectByHrReportPage',
        exportXlsUrl: '/projectBuild/personProjectByHrExport',
      },
      showSearchForm: false,
      keyword: '',
      labelCol: { span: 8 },
      wrapperCol: { span: 15 },
      queryParam: {
        searchField: 'projectNo',
        maType: 1,
      },
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '50', '100'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
      },
    }
  },
  created(){
  },
  mounted() {},
  computed: {},
  methods: {
    handleToSearch() {
      this.showSearchForm = false
      this.searchQuery()
    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.searchField = 'projectNo'
      this.handleToSearch()
    },
    showLength(item, len) {
      if (!item || item.length <= len) {
        return item
      }
      return item.substring(0, len) + '...'
    },
  },
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/hte-main.less';
@media (max-width: 1170px) {
  .page-main .container section .list-content > div.flex-num1-box {
    flex-wrap: wrap;
    > div {
      &:nth-child(1),
      &:nth-child(2) {
        width: 48%;
      }
      &:nth-child(3) {
        width: 100%;
        justify-content: flex-start;
        > span {
          margin-right: 20px;
          margin-left: 0;
        }
      }
    }
  }
  .page-main .container section .list-content > div.flex-num2-box {
    display: block;
    margin-top: 0;
  }
}
</style>